﻿using Stats.Distribution;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Stats.Test
{
    
    /// <summary>
    ///This is a test class for StandardBaseTest and is intended
    ///to contain all StandardBaseTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StandardBaseTest
    {

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Medium with no values
        ///</summary>
        [TestMethod()]
        public void MediumZeroTest()
        {
            StandardBase target = new StandardBase();
            double actual;
            actual = target.Medium;
            Assert.AreEqual(0.0, actual);
        }

        /// <summary>
        ///A test for Medium
        ///</summary>
        [TestMethod()]
        public void MediumTest()
        {
            StandardBase target = new StandardBase();
            target.Add(4.0);
            target.Add(9.0);
            target.Add(11.0);
            target.Add(12.0);
            target.Add(17.0);
            target.Add(5.0);
            target.Add(8.0);
            target.Add(12.0);
            target.Add(14.0);

            double actual;
            actual = target.Medium;
            Assert.AreEqual(11.0, actual);
        }

        /// <summary>
        ///A test for Mean
        ///</summary>
        [TestMethod()]
        public void MeanTest()
        {
            StandardBase target = new StandardBase();
            target.Add(4.0);
            target.Add(9.0);
            target.Add(11.0);
            target.Add(12.0);
            target.Add(17.0);
            target.Add(5.0);
            target.Add(8.0);
            target.Add(12.0);
            target.Add(14.0);

            Double expected = 10.22222;

            Double actual;
            actual = target.Mean;
            Assert.AreEqual(expected, Math.Round(actual, 5));
        }

        /// <summary>
        ///A test for Variance
        ///</summary>
        [TestMethod()]
        public void VarianceTest()
        {
            StandardBase target = new StandardBase();
            target.Add(4.0);
            target.Add(9.0);
            target.Add(11.0);
            target.Add(12.0);
            target.Add(17.0);
            target.Add(5.0);
            target.Add(8.0);
            target.Add(12.0);
            target.Add(14.0);

            Double expected = 17.44444;

            double actual;
            actual = target.Varience;
            Assert.AreEqual(expected, Math.Round(actual, 5));
        }

        /// <summary>
        ///A test for σ
        ///</summary>
        [TestMethod()]
        public void σTest()
        {
            StandardBase target = new StandardBase();
            target.Add(4.0);
            target.Add(9.0);
            target.Add(11.0);
            target.Add(12.0);
            target.Add(17.0);
            target.Add(5.0);
            target.Add(8.0);
            target.Add(12.0);
            target.Add(14.0);

            double actual;
            actual = target.σ;
            Assert.AreEqual(4.18, Math.Round(actual, 2));
        }

        /// <summary>
        ///A test for zScore
        ///</summary>
        [TestMethod()]
        public void zScoreTest()
        {
            StandardBase target = new StandardBase();
            target.Add(4.0);
            target.Add(9.0);
            target.Add(11.0);
            target.Add(12.0);
            target.Add(17.0);
            target.Add(5.0);
            target.Add(8.0);
            target.Add(12.0);
            target.Add(14.0);

            double X = 10.0;
            double expected = -0.05321;
            double actual;
            actual = target.zScore(X);
            Assert.AreEqual(expected, Math.Round(actual, 5));
        }
    }
}
